import {MainData} from "../../coreModule/data/BaseData";
import {field} from "../../coreModule/data/DataLoader";
import {TaskType} from "../../taskModule/data/Task";
import {dataClass} from "../../coreModule/managers/DataManager";
import {BaseRepository, getRepository, repository} from "../../coreModule/data/BaseRepository";
import {Constructor} from "../../../utils/BaseContext";

export enum RoleType {
	Normal, Instructor, School, Company
}

@dataClass("Role")
export class Role extends MainData {

	@field(String)
	public name: string;
	@field
	public type: RoleType = RoleType.Normal;
	@field
	public needAuth: boolean = true;
	@field([String])
	public fields: string[] = [];
	@field([Number])
	public particTypes: TaskType[] = [];
	@field([Number])
	public publishTypes: TaskType[] = [];
	@field
	public useBond: boolean = true;
}

@dataClass("InstructorLevel")
export class InstructorLevel extends MainData {

	@field
	public level: number = 1;
	@field(String)
	public name: string;
	@field(String)
	public privilege: string;
}

export function roleRepo() {
	return getRepository(RoleRepo);
}

@repository
class RoleRepo extends BaseRepository<Role> {

	get clazz(): Constructor<Role> { return Role; }
	public constructor() { super(); }

	// @ts-ignore
	public findByNeedAuth(needAuth: boolean): Role[] {}

	// @ts-ignore
	public getByType(type: RoleType): Role {}

}

export function iLevelRepo() {
	return getRepository(InstructorLevelRepo);
}

@repository
class InstructorLevelRepo extends BaseRepository<InstructorLevel> {

	get clazz(): Constructor<InstructorLevel> { return InstructorLevel; }
	public constructor() { super(); }

	// @ts-ignore
	public getByLevel(level: number): InstructorLevel {}

}
